package cn.rmc.hrm.exception;

import cn.rmc.hrm.util.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 处理异常
 */
@RestControllerAdvice
public class CommonExceptionHandler {
//    全局异常
    @ExceptionHandler(value = GlobalException.class)
    public AjaxResult handlerGloBalException(GlobalException g){
        return AjaxResult.me().setSuccess(false).setMessage(g.getMessage());
    }
//    其他异常
    @ExceptionHandler(value = Exception.class)
    public AjaxResult handlerException(Exception e){
        return AjaxResult.me().setSuccess(false).setMessage("系统错误了TMD");
    }
}
